import komand
from .schema import UploadMalwareInput, UploadMalwareOutput, Input, Output, Component
from ...util import project


class UploadMalware(komand.Action):

    def __init__(self):
        super(self.__class__, self).__init__(
                name='upload_malware',
                description=Component.DESCRIPTION,
                input=UploadMalwareInput(),
                output=UploadMalwareOutput())

    def run(self, params={}):
        return {
            Output.MALWARE: project.Project(self.connection.config, params.get(Input.PROJECT_NAME)).upload_malware(
                params.get(Input.FILE),
                params.get(Input.EXTRACTOR),
                params.get(Input.TAGS),
                params.get(Input.PASSWORD),
                params.get(Input.STORE_ARCHIVE),
                params.get(Input.NOTE_TITLE),
                params.get(Input.NOTE_BODY),
                params.get(Input.FILE_NAME)
            )
        }
